/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package UISUTModel.impl;

import UISUTModel.UIDataVariable;
import UISUTModel.UISUTModelPackage;
import UISUTModel.UIState;
import UISUTModel.UIStatemachine;
import UISUTModel.UITransition;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>UI Statemachine</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link UISUTModel.impl.UIStatemachineImpl#getItsState <em>Its State</em>}</li>
 *   <li>{@link UISUTModel.impl.UIStatemachineImpl#getItsTransition <em>Its Transition</em>}</li>
 *   <li>{@link UISUTModel.impl.UIStatemachineImpl#getItsDataVariable <em>Its Data Variable</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class UIStatemachineImpl extends UISUTElementImpl implements UIStatemachine {
	/**
	 * The cached value of the '{@link #getItsState() <em>Its State</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getItsState()
	 * @generated
	 * @ordered
	 */
	protected EList<UIState> itsState;

	/**
	 * The cached value of the '{@link #getItsTransition() <em>Its Transition</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getItsTransition()
	 * @generated
	 * @ordered
	 */
	protected EList<UITransition> itsTransition;

	/**
	 * The cached value of the '{@link #getItsDataVariable() <em>Its Data Variable</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getItsDataVariable()
	 * @generated
	 * @ordered
	 */
	protected UIDataVariable itsDataVariable;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected UIStatemachineImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return UISUTModelPackage.Literals.UI_STATEMACHINE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<UIState> getItsState() {
		if (itsState == null) {
			itsState = new EObjectContainmentEList<UIState>(UIState.class, this, UISUTModelPackage.UI_STATEMACHINE__ITS_STATE);
		}
		return itsState;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<UITransition> getItsTransition() {
		if (itsTransition == null) {
			itsTransition = new EObjectContainmentEList<UITransition>(UITransition.class, this, UISUTModelPackage.UI_STATEMACHINE__ITS_TRANSITION);
		}
		return itsTransition;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public UIDataVariable getItsDataVariable() {
		return itsDataVariable;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetItsDataVariable(UIDataVariable newItsDataVariable, NotificationChain msgs) {
		UIDataVariable oldItsDataVariable = itsDataVariable;
		itsDataVariable = newItsDataVariable;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, UISUTModelPackage.UI_STATEMACHINE__ITS_DATA_VARIABLE, oldItsDataVariable, newItsDataVariable);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setItsDataVariable(UIDataVariable newItsDataVariable) {
		if (newItsDataVariable != itsDataVariable) {
			NotificationChain msgs = null;
			if (itsDataVariable != null)
				msgs = ((InternalEObject)itsDataVariable).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - UISUTModelPackage.UI_STATEMACHINE__ITS_DATA_VARIABLE, null, msgs);
			if (newItsDataVariable != null)
				msgs = ((InternalEObject)newItsDataVariable).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - UISUTModelPackage.UI_STATEMACHINE__ITS_DATA_VARIABLE, null, msgs);
			msgs = basicSetItsDataVariable(newItsDataVariable, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, UISUTModelPackage.UI_STATEMACHINE__ITS_DATA_VARIABLE, newItsDataVariable, newItsDataVariable));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case UISUTModelPackage.UI_STATEMACHINE__ITS_STATE:
				return ((InternalEList<?>)getItsState()).basicRemove(otherEnd, msgs);
			case UISUTModelPackage.UI_STATEMACHINE__ITS_TRANSITION:
				return ((InternalEList<?>)getItsTransition()).basicRemove(otherEnd, msgs);
			case UISUTModelPackage.UI_STATEMACHINE__ITS_DATA_VARIABLE:
				return basicSetItsDataVariable(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case UISUTModelPackage.UI_STATEMACHINE__ITS_STATE:
				return getItsState();
			case UISUTModelPackage.UI_STATEMACHINE__ITS_TRANSITION:
				return getItsTransition();
			case UISUTModelPackage.UI_STATEMACHINE__ITS_DATA_VARIABLE:
				return getItsDataVariable();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case UISUTModelPackage.UI_STATEMACHINE__ITS_STATE:
				getItsState().clear();
				getItsState().addAll((Collection<? extends UIState>)newValue);
				return;
			case UISUTModelPackage.UI_STATEMACHINE__ITS_TRANSITION:
				getItsTransition().clear();
				getItsTransition().addAll((Collection<? extends UITransition>)newValue);
				return;
			case UISUTModelPackage.UI_STATEMACHINE__ITS_DATA_VARIABLE:
				setItsDataVariable((UIDataVariable)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case UISUTModelPackage.UI_STATEMACHINE__ITS_STATE:
				getItsState().clear();
				return;
			case UISUTModelPackage.UI_STATEMACHINE__ITS_TRANSITION:
				getItsTransition().clear();
				return;
			case UISUTModelPackage.UI_STATEMACHINE__ITS_DATA_VARIABLE:
				setItsDataVariable((UIDataVariable)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case UISUTModelPackage.UI_STATEMACHINE__ITS_STATE:
				return itsState != null && !itsState.isEmpty();
			case UISUTModelPackage.UI_STATEMACHINE__ITS_TRANSITION:
				return itsTransition != null && !itsTransition.isEmpty();
			case UISUTModelPackage.UI_STATEMACHINE__ITS_DATA_VARIABLE:
				return itsDataVariable != null;
		}
		return super.eIsSet(featureID);
	}

} //UIStatemachineImpl
